/****************************************************************************
**  @copyright  TinKinG
**  @contract   lsnbing@126.com
**
**  @brief  封装gumbo库，以Dom方式去操作
**  @file   gumbo_ext.h
**  @author TinKinG
**  @date   2016-06-07
**
**
*****************************************************************************/

#ifndef _GUMBO_EXT_H
#define _GUMBO_EXT_H

#include <vector>
#include <string>
#include "gumbo.h"

typedef struct GumboInternalNode GumboNode;
typedef std::vector<GumboNode *> GumboNodeList;

GumboNodeList getElementsByTagName(GumboNode *node, const std::string & tag);
GumboNodeList getElementsByClassName(GumboNode * node,const std::string & className);
GumboNodeList getElementsByAttributeName(GumboNode *node,const std::string &attribute,const std::string &value);

GumboNodeList getElementsAll(GumboNode *node);
GumboNodeList getElementsSubAll(GumboNode *node);

//如果有重复的ID，仅返回第一个
GumboNode * getElementByClassNameAtFirst(GumboNode *node,const std::string & className);
GumboNode * getElementByTagNameAtFirst(GumboNode *node, const std::string & tag);
GumboNode * getElementByAttributeNameAtFirst(GumboNode *node,const std::string &attribute,const std::string &value);
GumboNode * getElementById(GumboNode *node,const std::string & value);
GumboNode * getElementByName(GumboNode *node, const std::string &value);
GumboNode * getPreviousElement(GumboNode *node);
GumboNode * getNextElement(GumboNode *node);
GumboNode * getParentNodeElement(GumboNode * node);

std::string getAttribute(GumboNode * node, const std::string &attrubute);
std::string getInnerText(GumboNode * node);
std::string getAttributeValue(GumboNode * node);
//std::string getInnerNodeText(GumboNode * node);

#endif
